<!DOCTYPE html>
<html lang="en">





<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" type="image/png" href="/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="My Personal Website For Blog">
  <meta name="author" content="黄宇辉">
  <meta name="keywords" content="learning note,hexo blog">
  <title>Lombok简介及基本使用 - 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/vs2015.min.css" />
  

  


<!-- 主题依赖的图标库，不要自行修改 -->
<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_yg9cfy8wd6.css">

<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">

<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/js/utils.js" ></script>
</head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>ANONYMOUS</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                Home
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                Archives
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                Tags
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                About
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="view intro-2" id="background" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container text-center white-text fadeInUp">
            <span class="h2" id="subtitle">
              
            </span>

            
              
  <div class="mt-3 post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2019-08-13 20:46">
      August 13, 2019 pm
    </time>
  </div>


<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.2k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      16
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <div class="post-content mx-auto" id="post">
            
            <article class="markdown-body">
              <h2 id="学习笔记-Lombok简介及基本使用"><a href="#学习笔记-Lombok简介及基本使用" class="headerlink" title="学习笔记 : Lombok简介及基本使用"></a>学习笔记 : Lombok简介及基本使用</h2><h3 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h3><p><em>问题引入 : 开发中经常需要写的JavaBean,都需要花时间去添加相应的getter/setter,也许还要去写构造器、equals等方法,而且需要维护,当属性多时会出现大量的getter/setter方法,这些显得很冗长也没有太多技术含量,一旦修改属性,就容易出现忘记修改对应方法的失误哟~</em></p>
<p><em>Lombok能通过注解的方式,在编译时自动为属性生成<code>构造器</code>、<code>getter/setter</code>、<code>equals</code>、<code>hashcode</code>、<code>toString</code>方法. 出现的神奇就是在源码中没有getter和setter方法,但是在编译生成的字节码文件中有getter和setter方法. 这样就省去了手动重建这些代码的麻烦,既而达到简化代码,提高开发人员的开发效率的目的</em></p>
<ul>
<li>优点 :<ul>
<li>能通过注解的形式自动生成构造器、getter/setter、equals、hashcode、toString等方法,提高了一定的开发效率</li>
<li>让代码变得简洁,不用过多的去关注相应的方法</li>
<li>属性做修改时,也简化了维护为这些属性所生成的getter/setter方法等</li>
</ul>
</li>
<li>缺点 :<ul>
<li>不支持多种参数构造器的重载</li>
<li>虽然省去了手动创建getter/setter方法的麻烦,但大大降低了源代码的可读性和完整性,降低了阅读源代码的舒适度</li>
</ul>
</li>
<li>总结 : <ul>
<li>Lombok虽然有很多优点,但Lombok更类似于一种IDE插件,项目也需要依赖相应的jar包. Lombok依赖jar包是因为编译时要用它的注解,为什么说它又类似插件 ? 因为在使用时Eclipse或IntelliJ IDEA都需要安装相应的插件,<code>在编译器编译时通过操作AST( 抽象语法树 )改变字节码生成,变向的就是说它在改变Java语法. 它不像Spring的依赖注入或者MyBatis的ORM一样是运行时的特性,而是编译时的特性</code></li>
</ul>
</li>
</ul>
<h3 id="开发环境"><a href="#开发环境" class="headerlink" title="开发环境"></a>开发环境</h3><ol>
<li><p><em>添加Maven依赖 :</em></p>
<div class="hljs"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.projectlombok<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>lombok<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>1.16.20<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">scope</span>&gt;</span>provided<span class="hljs-tag">&lt;/<span class="hljs-name">scope</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span></code></pre></div>
</li>
<li><p><em>安装IDEA(<code>IntelliJ Lombok plugin</code>)插件</em></p>
</li>
</ol>
<h3 id="常见异常"><a href="#常见异常" class="headerlink" title="常见异常"></a>常见异常</h3><ol>
<li><p><em>(已添加<code>lombok</code>依赖情况下)抛出此异常,(IDEA环境)解决方案:安装<code>IntelliJ Lombok plugin</code>并启用<code>Enable annotation processing</code></em></p>
<div class="hljs"><pre><code class="hljs stylus">Warning:(<span class="hljs-number">49</span>, <span class="hljs-number">8</span>) java: lombok<span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.apt</span><span class="hljs-selector-class">.LombokProcessor</span> could not be initialized. Lombok will not run during this compilation: java<span class="hljs-selector-class">.lang</span><span class="hljs-selector-class">.IllegalArgumentException</span>: com<span class="hljs-selector-class">.sun</span><span class="hljs-selector-class">.tools</span><span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.main</span>.DelegatingJavaFileManager<span class="hljs-variable">$DelegatingSJFM</span> extends com<span class="hljs-selector-class">.sun</span><span class="hljs-selector-class">.tools</span><span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.main</span><span class="hljs-selector-class">.DelegatingJavaFileManager</span> implements javax<span class="hljs-selector-class">.tools</span><span class="hljs-selector-class">.StandardJavaFileManager</span>
  	at lombok<span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.apt</span><span class="hljs-selector-class">.LombokFileObjects</span>.getCompiler(LombokFileObjects<span class="hljs-selector-class">.java</span>:<span class="hljs-number">148</span>)
  	at lombok<span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.apt</span><span class="hljs-selector-class">.InterceptingJavaFileManager</span>.&lt;init&gt;(InterceptingJavaFileManager<span class="hljs-selector-class">.java</span>:<span class="hljs-number">40</span>)
  	at lombok<span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.apt</span><span class="hljs-selector-class">.LombokProcessor</span>.placePostCompileAndDontMakeForceRoundDummiesHook(LombokProcessor<span class="hljs-selector-class">.java</span>:<span class="hljs-number">165</span>)
  	at lombok<span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.apt</span><span class="hljs-selector-class">.LombokProcessor</span>.init(LombokProcessor<span class="hljs-selector-class">.java</span>:<span class="hljs-number">87</span>)
  	at lombok<span class="hljs-selector-class">.core</span>.AnnotationProcessor<span class="hljs-variable">$JavacDescriptor</span>.want(AnnotationProcessor<span class="hljs-selector-class">.java</span>:<span class="hljs-number">87</span>)
  	at lombok<span class="hljs-selector-class">.core</span><span class="hljs-selector-class">.AnnotationProcessor</span>.init(AnnotationProcessor<span class="hljs-selector-class">.java</span>:<span class="hljs-number">140</span>)</code></pre></div>
</li>
<li><p><em>JDK版本bug,解决方案:重置JDK版本,Project Structure—&gt;Porject settings—&gt;Project : 将<code>Project SDK</code>设置为:<code>9(java version&quot;9.0.4&quot;)</code>, <code>language level</code>设置为<code>8</code>,详情操作请参考 : <a href="https://github.com/YUbuntu0109/YUbuntu0109.github.io/blob/ce0545de04d3cfc9b328a1760bb5f3c84d322362/source/_posts/%E8%AF%A6%E8%A7%A3%E5%9C%A8IDEA%E4%B8%AD%E5%A4%9A%E5%A4%84%E8%AE%BE%E7%BD%AEJDK%E5%8F%8A%E5%85%B6%E5%8C%BA%E5%88%AB.md" target="_blank" rel="noopener">IDEA为何多处设置JDK,有什么区别呢 ?</a></em></p>
<div class="hljs"><pre><code class="hljs stylus">Warning:(<span class="hljs-number">9</span>, <span class="hljs-number">8</span>) java: lombok<span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.apt</span><span class="hljs-selector-class">.LombokProcessor</span> could not be initialized. Lombok will not run during this compilation: java<span class="hljs-selector-class">.lang</span><span class="hljs-selector-class">.IllegalArgumentException</span>: com<span class="hljs-selector-class">.sun</span><span class="hljs-selector-class">.tools</span><span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.main</span>.DelegatingJavaFileManager<span class="hljs-variable">$DelegatingSJFM</span> extends com<span class="hljs-selector-class">.sun</span><span class="hljs-selector-class">.tools</span><span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.main</span><span class="hljs-selector-class">.DelegatingJavaFileManager</span> implements javax<span class="hljs-selector-class">.tools</span><span class="hljs-selector-class">.StandardJavaFileManager</span>
  	at lombok<span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.apt</span><span class="hljs-selector-class">.LombokFileObjects</span>.getCompiler(LombokFileObjects<span class="hljs-selector-class">.java</span>:<span class="hljs-number">148</span>)
  	at lombok<span class="hljs-selector-class">.javac</span><span class="hljs-selector-class">.apt</span><span class="hljs-selector-class">.InterceptingJavaFileManager</span>.&lt;init&gt;(InterceptingJavaFileManager<span class="hljs-selector-class">.java</span>:<span class="hljs-number">40</span>)</code></pre></div>


</li>
</ol>
<h3 id="使用Lombok前后对比"><a href="#使用Lombok前后对比" class="headerlink" title="使用Lombok前后对比"></a>使用Lombok前后对比</h3><ol>
<li><p><em>一个未使用Lombok的普通JavaBean</em></p>
<div class="hljs"><pre><code class="hljs java"><span class="hljs-keyword">package</span> pers.huangyuhui.lombok.bean;

<span class="hljs-keyword">import</span> org.apache.log4j.Logger;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">User</span> </span>&#123;

    <span class="hljs-keyword">private</span> Integer id;
    <span class="hljs-keyword">private</span> String name;
    <span class="hljs-keyword">private</span> String password;
    <span class="hljs-keyword">private</span> Logger log = Logger.getLogger(<span class="hljs-keyword">this</span>.getClass());

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">User</span><span class="hljs-params">()</span> </span>&#123;
    &#125;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">User</span><span class="hljs-params">(Integer id, String name, String password)</span> </span>&#123;
        <span class="hljs-keyword">this</span>.id = id;
        <span class="hljs-keyword">this</span>.name = name;
        <span class="hljs-keyword">this</span>.password = password;
    &#125;

    <span class="hljs-function"><span class="hljs-keyword">public</span> Integer <span class="hljs-title">getId</span><span class="hljs-params">()</span> </span>&#123;
        <span class="hljs-keyword">return</span> id;
    &#125;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setId</span><span class="hljs-params">(Integer id)</span> </span>&#123;
        <span class="hljs-keyword">this</span>.id = id;
    &#125;

    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">getName</span><span class="hljs-params">()</span> </span>&#123;
        <span class="hljs-keyword">return</span> name;
    &#125;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setName</span><span class="hljs-params">(String name)</span> </span>&#123;
        <span class="hljs-keyword">this</span>.name = name;
    &#125;

    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">getPassword</span><span class="hljs-params">()</span> </span>&#123;
        <span class="hljs-keyword">return</span> password;
    &#125;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setPassword</span><span class="hljs-params">(String password)</span> </span>&#123;
        <span class="hljs-keyword">this</span>.password = password;
    &#125;

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">toString</span><span class="hljs-params">()</span> </span>&#123;
        <span class="hljs-keyword">return</span> <span class="hljs-string">"User&#123;"</span> +
                <span class="hljs-string">"id="</span> + id +
                <span class="hljs-string">", name='"</span> + name + <span class="hljs-string">'\''</span> +
                <span class="hljs-string">", password='"</span> + password + <span class="hljs-string">'\''</span> +
                <span class="hljs-string">'&#125;'</span>;
    &#125;
&#125;</code></pre></div>
</li>
<li><p><em>一个使用Lombok的普通JavaBean( 使用Lombok注解达到与上述JavaBean同样的效果 )~</em></p>
</li>
</ol>
<ul>
<li><code>@Data</code> : 注解在类上,提供类所有属性的 getting 和 setting 方法,此外还提供了equals、canEqual、hashCode、toString方法</li>
<li><code>@Setter</code> : 注解在属性上,为属性提供 setting 方法</li>
<li><code>@Getter</code> : 注解在属性上,为属性提供 getting 方法</li>
<li><code>@Log4j</code> : 注解在类上,为类提供一个属性名为 log 的 log4j 日志对象</li>
<li><code>@ToString</code> : 注解在类上,为类提供一个 toString 方法</li>
<li><code>@NoArgsConstructor</code> : 注解在类上,为类提供一个无参的构造方法</li>
<li><code>@AllArgsConstructor</code> : 注解在类上,为类提供一个全参的构造方法</li>
</ul>
<div class="hljs"><pre><code class="hljs java"><span class="hljs-keyword">package</span> pers.huangyuhui.lombok.bean;


<span class="hljs-keyword">import</span> lombok.AllArgsConstructor;
<span class="hljs-keyword">import</span> lombok.Data;
<span class="hljs-keyword">import</span> lombok.NoArgsConstructor;
<span class="hljs-keyword">import</span> lombok.ToString;
<span class="hljs-keyword">import</span> lombok.extern.log4j.Log4j;

<span class="hljs-meta">@Data</span>
<span class="hljs-meta">@Log</span>4j
<span class="hljs-meta">@ToString</span>
<span class="hljs-meta">@NoArgsConstructor</span>
<span class="hljs-meta">@AllArgsConstructor</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">UserWithLombok</span> </span>&#123;

    <span class="hljs-keyword">private</span> Integer id;
    <span class="hljs-keyword">private</span> String name;
    <span class="hljs-keyword">private</span> String password;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">outLogInfo</span><span class="hljs-params">()</span> </span>&#123;
        log.info(<span class="hljs-string">"the message object to log ~"</span>);
    &#125;
&#125;</code></pre></div>



<p><em>参考链接 :</em></p>
<ul>
<li><a href="https://github.com/rzwitserloot/lombok" target="_blank" rel="noopener">https://github.com/rzwitserloot/lombok</a></li>
<li><a href="https://www.cnblogs.com/heyonggang/p/8638374.html" target="_blank" rel="noopener">https://www.cnblogs.com/heyonggang/p/8638374.html</a></li>
</ul>

            </article>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/Java/">Java</a>
                    
                      <a class="hover-with-bg" href="/tags/Lombok/">Lombok</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" target="_blank" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <div class="post-prev col-6">
                    
                    
                      <a href="/2019/08/14/SpringBoot%E6%95%B4%E5%90%88FreeMarker/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">SpringBoot整合FreeMarker</span>
                        <span class="visible-mobile">Previous</span>
                      </a>
                    
                  </div>
                  <div class="post-next col-6">
                    
                    
                      <a href="/2019/08/13/%E8%AF%A6%E8%A7%A3%E5%9C%A8IDEA%E4%B8%AD%E5%A4%9A%E5%A4%84%E8%AE%BE%E7%BD%AEJDK%E5%8F%8A%E5%85%B6%E5%8C%BA%E5%88%AB/">
                        <span class="hidden-mobile">详解在IDEA中多处设置JDK及其区别</span>
                        <span class="visible-mobile">Next</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </div>
                </div>
              
            </div>

            
          </div>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;TOC</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Search</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">keyword</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


    

    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: 'article.markdown-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "Lombok简介及基本使用&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    var path = "/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>







  
  
    <script>
      !function (e, t, a) {
        function r() {
          for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
          requestAnimationFrame(r)
        }

        function n() {
          var t = "function" == typeof e.onclick && e.onclick;
          e.onclick = function (e) {
            t && t(), o(e)
          }
        }

        function o(e) {
          var a = t.createElement("div");
          a.className = "heart", s.push({
            el: a,
            x: e.clientX - 5,
            y: e.clientY - 5,
            scale: 1,
            alpha: 1,
            color: c()
          }), t.body.appendChild(a)
        }

        function i(e) {
          var a = t.createElement("style");
          a.type = "text/css";
          try {
            a.appendChild(t.createTextNode(e))
          } catch (t) {
            a.styleSheet.cssText = e
          }
          t.getElementsByTagName("head")[0].appendChild(a)
        }

        function c() {
          return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
        }

        var s = [];
        e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
          setTimeout(e, 1e3 / 60)
        }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
      }(window, document);
    </script>
  














</body>
</html>
